< How to Add Character Portraits > by Dha Lau Hoo Catalog: Preparation Extract the original portraits Figure out the tile mapping Draw your own portraits Convert your own portraits to binary format Place your binary portraits in your ROM I. Preparation Before you start, you need these tools: 1. Pancake 2 2. SonMapEd 3. A hex editor 4. An image editor 5. Sega Genesis ROM checksum fixer And you should understand hexadecimal maths and know image editing skills. This document does not teach you how to use the above tools. II. Extract the original portraits Run Pancake 2, open your ROM, and choose Edit -> Decompress Art. In the following dialog, enter the address: 34A98, and give it a valid file name, for example: Portraits.bin III. Figure out the tile mapping Copy Portraits.bin to the folder of SonMapEd, and run SonMapEd. Make sure you have the following setting options: Select Game Format -> Sonic 3 & Knuckles Disable Tile Rendering -> Hide Duplicated Tiles in Frames Select Color Swapping -> No Color Swapping Select Image Importing -> Direct/Nearest Match to Current Palette Disable Image Importing -> Assume Corner is Background Now select File -> Load Data File -> Load Uncompressed Tile Graphics, and choose Portraits.bin, you will see some tile blocks at the bottom of the window, but the colors are messed up. So you need a correct palette. Open your hex editor, create a new file, and enter: 00 00 0E EE 02 22 08 AE 04 6A 02 48 04 4E 02 28 02 26 0C 66 08 42 0A CE 06 44 06 CE 00 8A 06 8C and save it as palette.bin Then go to SonMapEd, select File -> Load Data File -> Load Primary or Full Palette... and choose palette.bin, then you will see the tiles in correct colors. Now you need to spend some time to play the puzzle game. You have to use your mouse and keyboard to place the tiles on the picture. Each tile is 8x8, and the whole picture is 256x64. For how to use SonMapEd, refer to its documents. There are two things you must be aware of: 1. All four portraits are together as one picture. 2. Some small tiles are duplicated. They occur at multiple locations on the picture. After you have figured out the mappings, you can save it. Select File -> Save Data File -> Save Mappings... give it a valid filename and save it. The next time you can select File -> Load Data File -> Load Sprite Mappings to open it, so you don't have to play the puzzle game again. IV. Draw your own portraits In SonMapEd, select File -> Save to Image, and save the portraits as a BMP file. Then open it using your image editor. You will see all the duplicated tiles are purple (255, 0, 255). You should draw your own portraits based on this picture. Pay attention to these two issues: 1. The picture only has 16 colors (excluding purple) 2. Keep in mind that the duplicated tiles should be the identical. You may be able to create new tiles in SonMapEd. For how to use SonMapEd, refer to its documents. After you have finished, save your picture to a BMP file as well. V. Convert your own portraits to binary format Let's use SonMapEd again. After Step III, you should select File -> Load from Image -> Import Sprite over Active Frame... and open your own BMP file. If it's abnormal, you need to go to Step IV to take care of the two issues. If it's normal, congratulations! Now you need to save it to a binary file. Select File -> Save Data File -> Save Tile Graphics (Uncompressed)... and give it a valid file name, for example, NewPortraits.BIN VI. Place your binary portraits in your ROM This is the last step, you need to use the hex editor again. Open your ROM in the hex editor, go to the end of the file directly, and add the following code: (I will explain the meaning of XXYYZZ, now you can use FFFFFF temporarily) 33 FC 81 3C 00 C0 00 04 23 FC 94 0E 93 A0 00 C0 00 04 23 FC 96 [YY] 95 [ZZ] 00 C0 00 04 33 FC 97 [XX] 00 C0 00 04 23 FC 60 00 00 81 00 C0 00 04 4E 75 We must remember the address of the first instruction (the address of 33). Let's call it [Address_A]. We must also remember the address after the last instruction (the address after 75). Let's call it [Address_B]. It's obvious that [Address_B] = [Address_A] + 30 (hex). Now we should use a hex calculator to divide [Address_B] by two, then we will get XXYYZZ. For example, if [Address_B] is 26DEE0, then XXYYZZ should be 136F70. Your code should be updated as well: 33 FC 81 3C 00 C0 00 04 23 FC 94 0E 93 A0 00 C0 00 04 23 FC 96 [6F] 95 [70] 00 C0 00 04 33 FC 97 [13] 00 C0 00 04 23 FC 60 00 00 81 00 C0 00 04 4E 75 Be careful! [Address_A] and [Address_B] will have different values in your ROM! 26DEE0 is only an example. Next, let's open NewPortraits.BIN, copy and past the whole data to the end of your rom, after your code 4E 75. Then we should go to the address 6E8A of your ROM. You will find these hex code: 41 F9 00 03 4A 98 where 034A98 is the address of the original portraits. Let's modify the code to 4E B9 00 UU VV WW where UUVVWW is [Address_A]. Following this instruction, from 6E90 to 6F0B, there is a long segment of hex code. Let's change each of them to become 4E 71. So we have 4E 71 4E 71 4E 71... repeatedly until 6F0B. Then you will see 40 E7 00 7C 07 00 33 FC ... Don't change anything. Save your ROM. Lastly, let's use Sega Genesis ROM checksum fixer to fix the checksum and ROM size. Load your ROM with your emulator, and you will see the new portraits. 11/22/2018